There are essentially four parts to a function definition. They are the return type, the function name, the parameter list, and the function body, in that order. In this case:
•return type: int
•function name: main
•parameter list: ()
•function body: { ... }
A simple program main()
//include this
file for cout
#include
<iostream.h>
int main()
{
//print out the text string,
//"Hello, World!"
cout << "Hello,
World!"
<< endl;
return 0;
}
Every C++ program must have
what is known as a main function. When you run the program, the program will go
through every line of code in the main function and execute it. If your main is empty,
then your program will do nothing.
For now, the important
thing to remember is that the function body is the part enclosed in { ... }
("curly braces"). The { indicates the beginning of the function, and the } indicates
the end of the function. The function body is the stuff in between.